package five_Net;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10099);
        Socket s = ss.accept();
        InputStream is = s.getInputStream();
//        BufferedInputStream bis = new BufferedInputStream(is);

        byte[] bys = new byte[1024];
        int len;
//        while ((len = bis.read(bys)) != -1) {
//            System.out.println("receive:" + new String(bys, 0, len));
//        }
        len = is.read(bys);
        System.out.println("receive:" + new String(bys, 0, len));

//        BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
        OutputStream os = s.getOutputStream();
        os.write("I have received".getBytes());

//        bos.close();
//        bis.close();
//        is.close();
//        s.close();
        ss.close();
    }
}
